package com.hspedu.newData.dmsxl.链表.快慢指针;

import com.hspedu.newData.dmsxl.ds.ListNode;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-07 
 * @Version: 1.0
 */

public class LC2095删除链表的中间节点 {

    public ListNode deleteMiddle(ListNode head) {

        ListNode dummy = new ListNode(0,head);
        ListNode first = dummy;
        ListNode second = dummy;

        while (second.next != null && second.next.next != null){
            first = first.next;
            second = second.next.next;
        }
        first.next = first.next.next;

        return dummy.next;
    }

}
